WearableExtender

Helper class to add wearable extensions to notifications.

See Creating Notifications for Android Wear for more information on how to use this class.

To create a notification with wearable extensions:

  1. Create a NotificationCompat.Builder, setting any desired properties.
  2. Create a NotificationCompat.WearableExtender.
  3. Set wearable-specific properties using the add and set methods of NotificationCompat.WearableExtender.
  4. Call extend to apply the extensions to a notification.
  5. Post the notification to the notification system with the NotificationManagerCompat.notify(...) methods and not the NotificationManager.notify(...) methods.
Notification notification = new NotificationCompat.Builder(mContext)
        .setContentTitle("New mail from " + sender.toString())
        .setContentText(subject)
        .setSmallIcon(R.drawable.new_mail)
        .extend(new NotificationCompat.WearableExtender()
                .setContentIcon(R.drawable.new_mail))
        .build();
NotificationManagerCompat.from(mContext).notify(0, notification);

Wearable extensions can be accessed on an existing notification by using the WearableExtender(Notification) constructor, and then using the get methods to access values.

NotificationCompat.WearableExtender wearableExtender =
        new NotificationCompat.WearableExtender(notification);
List<Notification> pages = wearableExtender.getPages();

Constructors

Link copied to clipboard
constructor()
Create a NotificationCompat.WearableExtender with default options.
constructor(@NonNull notification: Notification)

Properties

Link copied to clipboard
Sentinel value for use with setHintScreenTimeout to keep the screen on for a longer amount of time when this notification is displayed on the screen.
Link copied to clipboard
Sentinel value for use with setHintScreenTimeout to keep the screen on for a short amount of time when this notification is displayed on the screen.
Link copied to clipboard
val SIZE_DEFAULT: Int = 0
Size value for use with setCustomSizePreset to show this notification with default sizing.
Link copied to clipboard
Size value for use with setCustomSizePreset to show this notification full screen.
Link copied to clipboard
val SIZE_LARGE: Int = 4
Size value for use with setCustomSizePreset to show this notification with a large size.
Link copied to clipboard
val SIZE_MEDIUM: Int = 3
Size value for use with setCustomSizePreset to show this notification with a medium size.
Link copied to clipboard
val SIZE_SMALL: Int = 2
Size value for use with setCustomSizePreset to show this notification with a small size.
Link copied to clipboard
val SIZE_XSMALL: Int = 1
Size value for use with setCustomSizePreset to show this notification with an extra small size.
Link copied to clipboard
Sentinel value for an action index that is unset.

Functions

Link copied to clipboard
Add a wearable action to this notification.
Link copied to clipboard
Adds wearable actions to this notification.
Link copied to clipboard
Add an additional page of content to display with this notification.
Link copied to clipboard
Add additional pages of content to display with this notification.
Link copied to clipboard
Clear all wearable actions present on this builder.
Link copied to clipboard
Clear all additional pages present on this builder.
Link copied to clipboard
Link copied to clipboard
Apply wearable extensions to a notification that is being built.
Link copied to clipboard
Get the wearable actions present on this notification.
Link copied to clipboard
Get a background image to be displayed behind the notification content.
Link copied to clipboard
Returns the bridge tag of the notification.
Link copied to clipboard
open fun getContentAction(): Int
Get the index of the notification action, if any, that was specified as the primary action.
Link copied to clipboard
open fun getContentIcon(): Int
Get an icon that goes with the content of this notification.
Link copied to clipboard
Get the gravity that the content icon should have within the notification display.
Link copied to clipboard
Get whether the content intent is available when the wearable device is not connected to a companion device.
Link copied to clipboard
Get the custom height in pixels for the display of this notification's content.
Link copied to clipboard
Get the custom size preset for the display of this notification out of the available presets found in NotificationCompat.WearableExtender, e.g.
Link copied to clipboard
Returns the dismissal id of the notification.
Link copied to clipboard
Get the intent to launch inside of an activity view when displaying this notification.
Link copied to clipboard
open fun getGravity(): Int
Get the gravity that this notification should have within the available viewport space.
Link copied to clipboard
Get a hint that this notification's BigPictureStyle (if present) should be converted to low-bit and displayed in ambient mode, especially useful for barcodes and qr codes, as well as other simple black-and-white tickets.
Link copied to clipboard
Get a hint that this notification's background should not be clipped if possible, and should instead be resized to fully display on the screen, retaining the aspect ratio of the image.
Link copied to clipboard
Get a hint that this notification's content intent will launch an Activity directly, telling the platform that it can generate the appropriate transitions
Link copied to clipboard
Get a hint that this notification's icon should not be displayed.
Link copied to clipboard
Get the duration, in milliseconds, that the screen should remain on for when this notification is displayed.
Link copied to clipboard
Get a visual hint that only the background image of this notification should be displayed, and other semantic content should be hidden.
Link copied to clipboard
Get the array of additional pages of content for displaying this notification.
Link copied to clipboard
Get whether the scrolling position for the contents of this notification should start at the bottom of the contents instead of the top when the contents are too long to display within the screen.
Link copied to clipboard
Set a background image to be displayed behind the notification content.
Link copied to clipboard
Sets a bridge tag for this notification.
Link copied to clipboard
Set an action from this notification's actions as the primary action.
Link copied to clipboard
Set an icon that goes with the content of this notification.
Link copied to clipboard
Set the gravity that the content icon should have within the notification display.
Link copied to clipboard
Set whether the content intent is available when the wearable device is not connected to a companion device.
Link copied to clipboard
Set the custom height in pixels for the display of this notification's content.
Link copied to clipboard
Set the custom size preset for the display of this notification out of the available presets found in NotificationCompat.WearableExtender, e.g.
Link copied to clipboard
Sets the dismissal id for this notification.
Link copied to clipboard
Set an intent to launch inside of an activity view when displaying this notification.
Link copied to clipboard
Set the gravity that this notification should have within the available viewport space.
Link copied to clipboard
Set a hint that this notification's BigPictureStyle (if present) should be converted to low-bit and displayed in ambient mode, especially useful for barcodes and qr codes, as well as other simple black-and-white tickets.
Link copied to clipboard
Set a hint that this notification's background should not be clipped if possible, and should instead be resized to fully display on the screen, retaining the aspect ratio of the image.
Link copied to clipboard
Set a hint that this notification's content intent will launch an Activity directly, telling the platform that it can generate the appropriate transitions.
Link copied to clipboard
Set a hint that this notification's icon should not be displayed.
Link copied to clipboard
Set a hint that the screen should remain on for at least this duration when this notification is displayed on the screen.
Link copied to clipboard
Set a visual hint that only the background image of this notification should be displayed, and other semantic content should be hidden.
Link copied to clipboard
Set whether the scrolling position for the contents of this notification should start at the bottom of the contents instead of the top when the contents are too long to display within the screen.